/* $Header: dsp.h,v 2.2 01/10/02 10:30:18 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME: dsp.h                                            */
/* ==================                                                  */
/*                                                                     */
/* Author: Joe Bush                                                    */
/*                                                                     */
/* COMMENT: This 'include' contains the function prototype and bit     */
/*          definitions for the status byte that the function returns. */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

#ifndef DSP_H
#define DSP_H

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/


/***************************************************************************/
/*
     This section documents the error codes generated by the Detector DSP.
     The lower nibble of the status word consists of a flag and 3 non-fatal
     errors.  More than one bit may be set if more than one error occurs.
     These errors will clear themselves when the cause is corrected.
     The upper nibble represents the fatal errors.  Only the first fatal
     error encountered is trapped.  These errors can only be cleared by
     resetting and re-booting the DSP.

             bit #:  7    6    5    4    3    2    1    0
                     |              |    |    |    |    |
                     |------\/------|    |    |    |    |-- Data Available
                            ||           |    |    |-- Input Buffer Not Filled
                            ||           |    |-- Output Buffer Not Read
                            ||           |-- Input Buffer Checksum Error
                            ||
                     0  0  0  0  =  No Fatal Errors - OK

                     0  0  0  1  =  Task_1K didn't finish before next call
                     0  0  1  0  =  Task_100 didn't finish before next call
                     0  0  1  1  =  Task_100 called before data was available

                     1  0  0  1  =  ROM Checksum Error
                     1  0  1  0  =  RAM Test Error
                     1  0  1  1  =  Register Test Error

     The RAM and Register Test fatal errors can only be generated by the
     first boot page of the DSP.  The ROM Checksum error can be generated
     by either page at start-up of that page.  The Task_ errors are generated
     by the second boot page operation and should not occur (except maybe
     during debug).
*/

/* The following are considered NON FATAL events */
#define DATA_AVAILABLE                    0x01
#define BUFFER_NOT_FILLED                 0x02
#define BUFFER_NOT_READ                   0x04
#define INPUT_CHECKSUM_FAIL               0x08

/* The following are considered FATAL events */
#define TASK_1K_FAIL                      0x10
#define TASK_100_FAIL                     0x20
#define TASK_100_EARLY                    0x30
#define ROM_FAIL                          0x90
#define RAM_FAIL                          0xA0
#define REGISTER_FAIL                     0xB0

#define SIG_DSP_TESTS_MASK                0xf0

/* This is retured when the DSP fails its first boot page diagnostic test
   and returns garbage, i.e. the code does not match any of the allowable
   codes for this test.
*/
#define SIG_DSP_DEAD                      0xFF
/***************************************************************************/


/*****************************/
/*   MACROS                  */
/*****************************/


/*****************************/
/*   TYPEDEFS                */
/*****************************/


/*****************************/
/*   FUNCTION PROTOTYPES     */
/*****************************/

U_INT8 InitializeSignalDSP (void);
void   InitializePneumaticDSP (BIT8 LoadOld);

#endif
